package snafu.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;

import snafu.controller.WorldController;
import snafu.framework.worlds.WorldMap;
import snafu.framework.worlds.WorldMapPanel;

public class MainFrame extends JFrame {
	public MainFrame(WorldController controller) {
		super("snafu");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		getContentPane().setLayout(new BorderLayout());
		
		// information
		InformationPanel informationPanel = new InformationPanel(controller);
		controller.addObserver(informationPanel);
		getContentPane().add(informationPanel, BorderLayout.NORTH);
		
		// map
		WorldMap map = controller.getWorldMap();
		WorldMapPanel mapPanel = map.getRepresentation();
		controller.addObserver(mapPanel);
		getContentPane().add(mapPanel, BorderLayout.CENTER);
		
		// details
		DetailsPanel detailsPanel = new DetailsPanel(map, mapPanel);
		controller.addObserver(detailsPanel);
		getContentPane().add(detailsPanel, BorderLayout.EAST);
		
		// control
		ControlPanel controlPanel = new ControlPanel(controller);
		controller.addObserver(controlPanel);
		getContentPane().add(controlPanel, BorderLayout.SOUTH);
		
		setPreferredSize(new Dimension(300, 300));
		pack();
		setVisible(true);
	}
}
